function [images,labels] =  loadimage(imageFile,labelFile)
%imageFile = 't10k-images.idx3-ubyte';
%labelFile = 't10k-labels.idx1-ubyte';
% LABELS
% tic;
fid = fopen(labelFile,'r');
labelHeaderSize = 8;
header = fread(fid,labelHeaderSize,'uchar');
labels = fread(fid,inf,'uchar');
fclose(fid);
n = length(labels);

% IMAGES
side = 28;
nPixel = side*side;

% SLURP
fid = fopen(imageFile,'r','b');
imageHeaderSize = 16;
header = fread(fid,imageHeaderSize,'uchar');

data = fread(fid,nPixel*n,'uchar');
images = reshape(data,nPixel,[]);

for i = 1:n
    image1 = reshape(images(:,i),side,side)';
    image2 = deslant(image1);
    images(:,i) = image2(:);
    subplot(1,2,1);
    imagesc(image1);
    subplot(1,2,2);
    imagesc(image2);
    drawnow;
    pause;
end

labels = labels';
end